package com.yanqu.road.entity.activity.stelesoul.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_s_activity_stonesoul_review")
public class SteleSoulReviewConfig {
    @FieldTypeAnnotation(desc = "活动id", select = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "层数")
    private int layer;
    @FieldTypeAnnotation(desc = "大奖(道具id=数量）")
    private String award;
    @FieldTypeAnnotation(desc = "是否预览大奖")
    private int isReview;
    @FieldTypeAnnotation(desc = " 奖励列表（道具id=数量;道具id=数量；道具id=数量）")
    private String rewardList;
    @FieldTypeAnnotation(desc = " 奖励列表（道具id=数量;道具id=数量；道具id=数量）")
    private String selectReward;

    private List<Property> chosenRewards = new ArrayList<>();

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getLayer() {
        return layer;
    }

    public void setLayer(int layer) {
        this.layer = layer;
    }

    public String getAward() {
        return award;
    }

    public void setAward(String award) {
        this.award = award;
    }

    public int getIsReview() {
        return isReview;
    }

    public void setIsReview(int isReview) {
        this.isReview = isReview;
    }

    public String getRewardList() {
        return rewardList;
    }

    public void setRewardList(String rewardList) {
        this.rewardList = rewardList;
    }

    public List<Property> getChosenRewards() {
        return new ArrayList<>(chosenRewards);
    }

    public String getSelectReward() {
        return selectReward;
    }

    public void setSelectReward(String selectReward) {
        if (selectReward == null) {
            selectReward = "";
        }
        this.selectReward = selectReward;

        if (!StringUtils.isNullOrEmpty(selectReward)) {
            List<Property> temp = new ArrayList<>();
            for (String s : this.selectReward.split("\\|")) {
                Property property = PropertyHelper.parseStringToProperty(s);
                temp.add(property);
            }
            this.chosenRewards = temp;
        }
    }
}
